package cn.edu.huanu.servletlearn;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/**
 * @author hb
 * @date 2025-09-28 15:47:48
 */
@WebServlet("/sa")
public class ServletA extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        System.out.println("ServletA 执行 1。。。。");

        //向请求数据中绑定参数
        req.setAttribute("key","from ServletA...");

        //执行转发
        //req.getRequestDispatcher("/sb").forward(req,resp);
        resp.sendRedirect("sb");


        System.out.println("ServletA 执行 2。。。。");

    }
}
